package com.oh.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.provider.BaseColumns;

/**
 * 
 * 
 * @author Alex.Lu
 * 
 */
public class DatabaseHelper extends SQLiteOpenHelper {

	private static final int VERSION = 1;
	private static final String NAME = "/sdcard/sd_sys.db";
	private static DatabaseHelper instatnce;

	private DatabaseHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	public static DatabaseHelper getInstance(Context context) {
		if (instatnce == null) {
			instatnce = new DatabaseHelper(context, NAME, null, VERSION);
		}
		return instatnce;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub

		StringBuffer sbuf = new StringBuffer();
		sbuf.append("CREATE TABLE ");
		sbuf.append(Sreach_TB.TABLE_NAME);
		sbuf.append(" (");
		sbuf.append(Sreach_TB._ID);
		sbuf.append(" INTEGER,");
		sbuf.append(Sreach_TB.SREACH);
		sbuf.append(" TEXT");
		sbuf.append(");");
		db.execSQL(sbuf.toString());
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

	public static final class Sreach_TB implements SreachHistoryColumns,BaseColumns {
		public static final String TABLE_NAME = "tb_test";
	}


	public interface SreachHistoryColumns {
		String SREACH = "record_name";
	}


}
